<?Php
	require_once('../Model/getconfig.php');
	require_once('includes/checksession.php');
	$userid=$_SESSION["adminuser"];



			if(isset($_POST['textoldpassword'])) $oldpassword=$_POST['textoldpassword'];
			if(isset($_POST['textnewpassword'])) $password=$_POST['textnewpassword'];
			if(isset($_POST['textconfirmpassword'])) $confirmpassword=$_POST['textconfirmpassword'];

	if($password==$confirmpassword)
	{
			
			
		$arrMenu=Model_membermaster::get_admin_details($id);
		foreach($arrMenu as $objMenu){ 
		 $existingpassword=$objMenu->getPassword(); 
	
		}	
		if($existingpassword==$oldpassword)
		{
			$intuserid="";
			$pn_id=$_SESSION["adminid"];	
			$custsql="update admin set adminpassword='$password' where adminpassword='$oldpassword' and adminid=$pn_id";		
			$objDbManager=new Dbo_DbManager();
			$intMemmasterId=$objDbManager->dbexecute($custsql);	
			$success=TRUE;

?>

<?php
		}
		else
		{
				$hasError = true;
				$errorMessage = "Invalid old  password ( Please try again)!";		

		}
	}
	else
	{
				$hasError = true;
				$errorMessage = "New password and confirm password are not matching( Please try again)!";		
	}
?>
<?php if(isset($success) == true) { ?>
	<div class="ok_box">
		<h3>Thanks, <?php echo $name;?></h3>
		<p>Your password updated successfully.</p>
	</div>
<?php } ?>

<?php if(isset($hasError) ) { ?>
	<div class="error_box">
		There was an error submitting the form.
		<br />
		<?php echo $errorMessage;?>
	</div>
<?php } ?>